# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=wasm-pack
pkgver=0.12.1
pkgrel=2
pkgdesc="rust to wasm build tool"
url="https://github.com/rustwasm/wasm-pack"
arch="all !ppc64le !s390x !riscv64" # ring
license="Apache-2.0"
depends="cargo rust-wasm"
makedepends="
	bzip2-dev
	cargo-auditable
	curl-dev
	openssl-dev>3
	wasi-sdk
	zstd-dev
	"
source="https://github.com/rustwasm/wasm-pack/archive/refs/tags/v$pkgver/wasm-pack-v$pkgver.tar.gz"
options="net !check" # most tests fail outside of x86_64

export OPENSSL_NO_VENDOR=1

prepare() {
	default_prepare

	# Rust target triple.
	local target=$(rustc -vV | sed -n 's/host: //p')

	# Build against system-provided libzstd.
	mkdir -p .cargo
	cat >> .cargo/config.toml <<-EOF
		[target.$target]
		zstd = { rustc-link-lib = ["zstd"] }
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/wasm-pack \
		-t "$pkgdir"/usr/bin
}

sha512sums="
1887ec7474e016aa2f2c367737c68687b89b91e4991d6cfd74e930df742655a0d35f401c6af4a1ce7e396ee645b7be5b5aa5cfe889b328d5d6c4f7a0c7a63b3c  wasm-pack-v0.12.1.tar.gz
"
